/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.zzz.view.util;

import java.awt.Dimension;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.JFrame;

/**
 * 专门做界面效果的类
 * @author ASUS
 */
public class UiUtil {
    private UiUtil(){
    }
        //修改窗体的图标
        public static void setFrameImage(JFrame jf){
            //获取工具类对象
            Toolkit tk=Toolkit.getDefaultToolkit();
            
            //根据路径获取图片
            String filename="";
            Image i=tk.getImage(filename);
            
            //给窗体设置图片
            jf.setIconImage(i);
        }
        
        //设置窗体居中
        public static void setFrameCenter(JFrame jf){
            Toolkit tk=Toolkit.getDefaultToolkit();
            Dimension d=tk.getScreenSize();
            double screenWidth=d.getWidth();
            double screenHeight=d.getHeight();
            int frameWidth=jf.getWidth();
            int frameHeight=jf.getHeight();
            
            int width=(int)(screenWidth-frameWidth)/2;
            int height=(int)(screenHeight-frameHeight)/2;
            
            //设置窗体坐标
            jf.setLocation(width,height);
        }
}

